package mq

import (
	"context"

	"github.com/lab-online/pkg/logger"
	"github.com/lab-online/pkg/mq"
)

func (m *MQ) ConsumeContent(ctx context.Context, consumer func(delivery *mq.Delivery)) error {
	if _, err := m.RegisterConsumer(
		mq.QueueDeclareConfig{
			Name:    reportContentQueue,
			Durable: true,
		},
		mq.ConsumerConfig{
			Ctx:   ctx,
			Queue: reportContentQueue,
		},
		consumer,
	); err != nil {
		logger.Error("experiment content message consuming failed", "error", err.Error())
		return err
	}

	return nil
}
